<?php
class Category extends  BZ_Controller
{
    public function _init()
    {
        $this->load->model('tourism_goods_category_model', 'tourism_goods_category');
        $this->load->model('tourism_key_word_model', 'tourism_key_word');
    }

    public function index()
    {
        $category = $this->tourism_goods_category->find(array('level'=>2));
        if($category->num_rows() > 0){
            $row = $category->first_row();
            $data['subordinate'] = $this->tourism_goods_category->find(array('level'=>3, 'parent_id'=>$row->id));
        }
        $this->data['category'] = $category;
        $this->data['keyWordList'] = $this->tourism_key_word->findByParams(['provider_id' => $this->providerUid, 'status' => 1]);
        $this->load->view('tourism/category/index', $this->data);
    }

    public function ajaxChildrenCategory()
    {
        $parentId = $this->input->post('pranetId');
        $data['subordinate'] = $this->tourism_goods_category->find(array('level'=>3, 'parent_id'=>$parentId));
        echo json_encode(array(
            'html' => $this->load->view('tourism/category/ajaxcategory', $data, true)
        ));exit;
    }
}